package com.zeratul.demo.domain;


import com.zeratul.web.validate.annotation.ZtValid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import java.io.Serializable;

@Data
@ZtValid(message = "手机登录时，手机号不能为空", spel = "type == 0 ? phone != null : true")
@ZtValid(message = "账号登录时，用户名不能为空", spel = "type == 1 ? username != null : true")
public class User implements Serializable {

    /**
     * 登录类型 0-手机号登录 1-用户名登录
     */
    @NotNull(message = "{10000}")
    @Range(min = 0, max = 1, message = "登录类型不正确")
    private Integer type;

    /**
     * 用户名
     */
    private String username;

    /**
     * 手机号
     */
    private String phone;

    @NotBlank(message = "密码不能为空")
    @Size(min = 3, max = 6, message = "密码长度为{min}到{max}")
    private String password;
}
